package edu.whu.puppygo.dao;

import edu.whu.puppygo.entity.PetMatter;
import edu.whu.puppygo.entity.Post;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PostDao extends JpaRepository<Post, Long>, JpaSpecificationExecutor<Post> {
    @Query("select p from Post p where p.nickname = ?1 and p.deleteTime is null")
    List<Post> findByNickname(String nickname, Pageable pageable);

    @Query("select p from Post p where p.userId = ?1 and p.deleteTime is null")
    List<Post> findByUserId(Long useId, Pageable pageable);

    @Query("select p from Post p where p.deleteTime is null")
    List<Post> findAllByDeleteTimeNull(Pageable pageable);
}
